package com.katus;

import com.katus.entity.Book;
import com.katus.entity.Student;
import com.katus.service.BookService;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.util.Objects;

/**
 * @author SUN Katus
 * @version 1.0, 2021-07-12
 */
public class SpringApplication {

    public static void main(String[] args) {
        ApplicationContext context = new FileSystemXmlApplicationContext(Objects.requireNonNull(SpringApplication.class.getClassLoader().getResource("springConfig.xml")).getFile());
        BookService bookService = context.getBean("bookServiceImpl", BookService.class);
        bookService.query();
        Book book1 = context.getBean("book", Book.class);
        Book book2 = context.getBean("book", Book.class);
        System.out.println(book1);
        System.out.println(book1 == book2);
        System.out.println(book1.equals(book2));
        Student student1 = context.getBean("student", Student.class);
        Student student2 = context.getBean("student", Student.class);
        System.out.println(student1);
        System.out.println(student1 == student2);
        System.out.println(student1.equals(student2));
    }

    @Test
    public void test() {
        // todo: 自己尝试的其他测试
    }
}
